#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > ccsdr12_bh.info <<'%EOF%'
   ccsdr12_bh
   -----------
   Molecule:         BH 
   Wave Function:    CCSD(R12)/A1/B / aug-cc-pVDZ + aug-cc-pVDZ
   Test Purpose:     Check CCSD(R12)/A1/B method with auxiliary basis 
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > ccsdr12_bh.mol <<'%EOF%'
INTGRL
BH                                                                            
aug-cc-pVDZ + aug-cc-pVDZ
    4  0 2  X  Y      0.10D-14
 1      5.    1    3    3    2    1
B        0.0000000000000     0.0000000000000     0.0000000000000
H   9    1
     4570.0000000000        0.0006960000
      685.9000000000        0.0053530000
      156.5000000000        0.0271340000
       44.4700000000        0.1013800000
       14.4800000000        0.2720550000
        5.1310000000        0.4484030000
        1.8980000000        0.2901230000
        0.3329000000        0.0143220000
        0.1043000000       -0.0034860000
H   9    1
     4570.0000000000       -0.0001390000  
      685.9000000000       -0.0010970000  
      156.5000000000       -0.0054440000  
       44.4700000000       -0.0219160000  
       14.4800000000       -0.0597510000  
        5.1310000000       -0.1387320000  
        1.8980000000       -0.1314820000  
        0.3329000000        0.5395260000  
        0.1043000000        0.5807740000  
F   2    0
        0.1043000000  
        0.0310500000  
H   4    1
        6.0010000000        0.0354810000  
        1.2410000000        0.1980720000  
        0.3364000000        0.5052300000  
        0.0953800000        0.4794990000  
F   2    0
        0.0953800000    
        0.0237800000    
F   2    0
        0.3430000000    
        0.0904000000    
 1      1.    1    2    2    1
H        0.0000000000000     0.0000000000000     2.3288983083247
H   4    1
       13.0100000000        0.0196850000  
        1.9620000000        0.1379770000  
        0.4446000000        0.4781480000  
        0.1220000000        0.5012400000  
F   2    0
        0.1220000000    
        0.0297400000    
F   2    0
        0.7270000000    
        0.1410000000    
 2      5.    1    3    3    2    1
B        0.0000000000000     0.0000000000000     0.0000000000000
H   9    1
     4570.0000000000        0.0006960000
      685.9000000000        0.0053530000
      156.5000000000        0.0271340000
       44.4700000000        0.1013800000
       14.4800000000        0.2720550000
        5.1310000000        0.4484030000
        1.8980000000        0.2901230000
        0.3329000000        0.0143220000
        0.1043000000       -0.0034860000
H   9    1
     4570.0000000000       -0.0001390000  
      685.9000000000       -0.0010970000  
      156.5000000000       -0.0054440000  
       44.4700000000       -0.0219160000  
       14.4800000000       -0.0597510000  
        5.1310000000       -0.1387320000  
        1.8980000000       -0.1314820000  
        0.3329000000        0.5395260000  
        0.1043000000        0.5807740000  
F   2    0
        0.1043000000  
        0.0310500000  
H   4    1
        6.0010000000        0.0354810000  
        1.2410000000        0.1980720000  
        0.3364000000        0.5052300000  
        0.0953800000        0.4794990000  
F   2    0
        0.0953800000    
        0.0237800000    
F   2    0
        0.3430000000    
        0.0904000000    
 2      1.    1    2    2    1
H        0.0000000000000     0.0000000000000     2.3288983083247
H   4    1
       13.0100000000        0.0196850000  
        1.9620000000        0.1379770000  
        0.4446000000        0.4781480000  
        0.1220000000        0.5012400000  
F   2    0
        0.1220000000    
        0.0297400000    
F   2    0
        0.7270000000    
        0.1410000000    
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > ccsdr12_bh.dal <<'%EOF%'

**DALTON INPUT
.RUN WAVE FUNCTION
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF IN  
.THRESH
 1.0D-12
*CC INPUT
.CCSD
.PRINT
 4 
.FROIMP
  1 0 0 0 
  0 0 0 0 
.THRENR
 1.0D-12
.MAX IT
 300
*R12 INPUT
#.NO HYB
#.R12XXL
#.NO A
#.NO A'
#.NO 2
.CC2
 1B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >ccsdr12_bh.check
cat >>ccsdr12_bh.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#            Total SCF   energy:                   -25.1264273369
#            Total MP2-R12/B energy:               -25.2006[78]
#            Total CCSD(R12)/B energy:             -25.2240489668



CRIT1=`$GREP "Total MP2-R12/B energy: *  \-25\.2006[78]" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CCSD\(R12\)/B energy: *  \-25\.224048966(7|8)" $log | wc -l`
TEST[2]=`expr	$CRIT2`
CTRL[2]=2
ERROR[2]="CCSD(R12)/B ENERGY NOT CORRECT"
#

PASSED=1
for i in 1 2
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
